package com.concurrent.sample.business.controller;

import com.concurrent.sample.business.entity.CashFlowEntity;
import com.concurrent.sample.business.service.CashFlowService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(path = "cash-flow")
@Slf4j
@RequiredArgsConstructor
public class CashFlowController {

  private final CashFlowService cashFlowService;

  /**
   * http://localhost:8081/cash-flow/insert
   * @param param
   * @return
   */
  @PostMapping(path = "/insert")
  public CashFlowEntity save(@RequestBody CashFlowEntity param){
    return cashFlowService.save(param);
  }

  @GetMapping(path = "/{id}")
  public CashFlowEntity getById(@PathVariable Long id){
    return cashFlowService.getById(id);
  }

}
